{include_core file="lib/header.html" title="我的售后" center="center"}
{include_core file="lib/top_nav.html"}
<div class="container">
  <div class="inner">
    <div class="con-top clearfix">
      {include_core file="lib/sidebar.html" crumbs_1="center" crumbs_2="service"}
      <div class="sale">
      {*
        <div class="sale-title clearfix">
          <h4>申请售后服务</h4>
          <span class="js_openLink" data-href="" data-target="_blank">售后政策</span>
        </div>
      *}
        <div class="barter">
          <h3>服务单号：{order_helper::order_id_encode($service_info.id, 2)}</h3>
          <div class="barter-list">
            <div class="barter-top">
              <ul class="clearfix">
                {$status = $service_info.refund_status}
                <li class="{if $status <= 20}barter-on{/if}"><a href="javascript:void(0);"><span>1</span>提交申请<em></em></a></li>
                <li class="{if $status == 1}curr{elseif $status > 1 && $status <= 20}barter-on{/if}"><a href="javascript:void(0);"><span>2</span>系统审核<em></em></a></li>
                <li class="{if $status >= 5 && $status < 20}curr{elseif $status > 15 && $status <= 20}barter-on{/if}"><a href="javascript:void(0);"><span>3</span>{if $service_info.type == 1}退货{elseif $service_info.type == 2}换货{else}维修{/if}<em></em></a></li>
                <li class="{if $status == 20 && $status <= 20}curr{/if}"><a href="javascript:void(0);"><span>4</span>完成</a></li>
              </ul>
            </div>
            <div class="barter-bot">
              <div class="bot1">
                {if $service_info.type < 3}
                <h2>处理时间</h2>
                <div class="clearfix">
                  <p>{$service_info.add_time}　服务已申请，请您等待客服的联系</p>
                  {if $service_info.refund_status == 1}
                  <!-- <a class="barter-num" href="javascript:void(0);">提醒客服</a> -->
                  {/if}
                </div>
                {if $service_info.agree_time != '0000-00-00 00:00:00' && $service_info.refund_status >= 5 && $service_info.refund_status < 25}
                <div class="clearfix">
                  <p>{$service_info.agree_time}　商家已同意，请您发货并告知商家</p>
                </div>
                {/if}
                {if $service_info.user_express_time != '0000-00-00 00:00:00' && $service_info.refund_status >= 10 && $service_info.refund_status < 25}
                <div class="clearfix">
                  <p>{$service_info.user_express_time}　商品寄送到商家</p>
                </div>
                {/if}
                {if $service_info.type == 1}
                  {if $service_info.refund_time != '0000-00-00 00:00:00' && $service_info.refund_status >= 15 && $service_info.refund_status < 25}
                  <div class="clearfix">
                    <p>{$service_info.refund_time}　退款中</p>
                  </div>
                  {/if}
                {else}
                  {if $service_info.refund_express_time != '0000-00-00 00:00:00' && $service_info.refund_status >= 15 && $service_info.refund_status < 25}
                  <div class="clearfix js_expressInfo" data-service_id="{$service_info.id}">
                    <p>{$service_info.refund_express_time}　商品寄回　{if $service_info.express_id}物流公司 :{_uri('express', $service_info.express_id, 'title')}　运单号码 :{$service_info.refund_express}{/if}</p>
                  </div>
                  {/if}
                {/if}
                {if $service_info.refund_status == 20}
                <div class="clearfix">
                  <p>{$service_info.update_time}　服务完成</p>
                </div>
                {/if}
                {if $service_info.refund_status == 23 && $service_info.refund_pay_status == 3}
                <div class="clearfix">
                  <p>{$service_info.update_time}  退款失败</p>
                </div>
                {/if}
                {if $service_info.refund_status == 23 && $service_info.refund_pay_status == 4}
                <div class="clearfix">
                  <p>{$service_info.update_time}  退款故障，请联系客服人工退款</p>
                </div>
                {/if}
                {if $service_info.refund_status == 25}
                <div class="clearfix">
                  <p>{$service_info.update_time}　服务取消</p>
                </div>
                {/if}
                {if $service_info.refund_status == 30}
                <div class="clearfix">
                  <p>{$service_info.update_time}　请求被驳回　驳回原因 :{$service_info.note}</p>
                </div>
                {/if}
                {else}
                <h2>处理时间</h2>
                <div class="clearfix">
                  <p>{$service_info.add_time}　维修服务已申请，请您耐心等待1-3个工作日，客服将主动联系您</p>
                  <!-- <a class="barter-num" href="javascript:void(0);">提醒客服</a> -->
                </div>
                {/if}
                <div class="barter-address" style="padding: 10px 0px">
                  <h2 style="padding-bottom: 8px;padding-top: 20px;">收货地址</h2>
                  <ul>
                    <li>姓　　名 :<span>{$service_info.receiver}</span></li>
                    <li>收货地址 :<span>{$service_info.province} {$service_info.city} {$service_info.district} {$service_info.address}</span></li>
                    <li>联系方式 :<span>{$service_info.mobile}</span></li>
                  </ul>
                </div>
                <div class="barter-shopp">
                  <h2>服务商品</h2>
                  {foreach $service_info.detail as $k=>$v}
                  <ul class="clearfix">
                    <li><a href="javascript:void(0);"><img src="{_image($v.goods_cover, 'small')}" width="80" /></a></li>
                    <li>
                      <h3>{$v.goods_title}</h3>
                      <p>{goods_helper::get_sku_property_value($v.sku_id)}</p>
                      <p>商品订单号：{order_helper::order_id_encode($service_info.order_id)}</p>
                    </li>
                    <li class="barter-c">{number_format($v.refund_price, 2)}元</li>
                  </ul>
                  {/foreach}
                </div>
                {if $service_info.refund_status == 15 && $service_info.type == 2}
                <div class="bot4"><div class="barter-affim js_sureRefundOver" data-id="{$service_info.id}"><a href="javascript:void(0);">确认收货</a></div></div>
                {/if}
              </div>
            </div>
          </div>
          <!--barter-list  end-->
        </div>
        <!--barter换货单  end-->
      </div>
    </div>
  </div>
</div>
<script>
  $(function(){
    $('.js_sureRefundOver').on('click', function(){
      var id = $(this).data('id');
      var url = siteUrl+'/service/sure_service';
      $.post(url, { id:id }, function(json){
        if (json.info == 'ok') {
          location.href = location.href;
        } else {
          showMsg(json.info);
        }
      }, 'json');
    });

    {if $service_info.express_id}
    getExpressInfo();
    {/if}
  })

  // 自动获取物流信息
  function getExpressInfo()
  {
    var serviceId = $('.js_expressInfo').data('service_id');
    var url     = siteUrl+'/express/ajax_express_info';
    var date    = new Date();
    var isView  = '';
      if (date.getMonth() < 9) {
        isView  = '0';
      }
    var tmpHtml = '<div class="clearfix js_expressTmpInfo"><p>'+date.getFullYear()+'-'+isView+(date.getMonth()+1)+'-'+date.getDate()+' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()+'　快递信息查询中...</p></div>';
    $('.js_expressInfo').after(tmpHtml);
    $.get(url, { service_id:serviceId }, function(json){
      var infoA = $('.js_expressInfo').find('a');
      var html = infoA.html();
      if (infoA.length > 0) {
        infoA.remove();
        $('.js_expressInfo').append('<p>'+html+'</p>');
      }
      if (json.info == 'ok') {
        var newHtml = '';
        var data = json.json.data;
        var dataLenght = data.length;
        for (var i = 0; i < dataLenght; i++) {
          var time = data[i]['time'].split(' ');
          if (i+1 == dataLenght && infoA.length > 0) {
            newHtml = newHtml + '<div class="clearfix"><p>'+time[0]+' '+time[1]+':00　'+data[i]['context']+'</p></div>';
          } else {
            newHtml = newHtml + '<div class="clearfix"><p>'+time[0]+' '+time[1]+':00　'+data[i]['context']+'</p></div>';
          }
        }
      } else {
        var newHtml = '<div class="clearfix"><p>'+date.getFullYear()+'-'+isView+(date.getMonth()+1)+'-'+date.getDate()+' '+date.getHours()+':'+date.getMinutes()+':'+date.getSeconds()+'　快递信息查询失败</p></div>';
      }
      $('.js_expressTmpInfo').remove();
      $('.js_expressInfo').after(newHtml);
    }, 'json');
  }
</script>
{include_core file="lib/footer.html"}